home *** CD-ROM | disk | FTP | other *** search
- Path: news.microsoft.com!news
- From: a-cnadc@microsoft.com (Dann Corbit)
- Newsgroups: comp.lang.c
- Subject: Re: f;oating point precision
- Date: 6 Mar 1996 02:28:28 GMT
- Organization: Microsoft Corporation
- Message-ID: <4hit8c$8lm@news.microsoft.com>
- References: <c0d_9603050128@csource.blaze.net.au>
- NNTP-Posting-Host: 157.57.171.202
- Mime-Version: 1.0
- X-Newsreader: WinVN 0.93.14
-
- In article <c0d_9603050128@csource.blaze.net.au>, David.Burrows@f158.n633.z3.fidonet.org says...
- >
- >Help.... I am getting floating point innaccuracies at about the 4th decimal
- >
- >place. eg i enter 510.0250 and it comes out as 510.0249.
- >I am just starting to learn c so please excuse my ignorance.
- > dave
- >
- >--
- >David.Burrows@f158.n633.z3.fidonet.org, David Burrows 3:633/158 (FidoNet)
- >
- Most people like to use base ten numbers in calculations. Computers store
- numbers in binary (base two). Performing this conversion from base ten to
- base two causes the problem that you see. In addition, a four byte IEEE
- float will hold six to seven decimal digits of accuracy. An eight byte
- double will hold about 15 digits of accuracy. Fixed word length limits the
- ability of computers to get exact results. We have similar limitations as
- humans when we express things in floating point. For instance, take the
- numbers 1/9 and 1/7 and express them as decimal numbers to as many places
- as you like. Then multiply the decimal expansions together. Multiply the
- result by 63. If you do it on paper, you won't get "1" unless you have used
- an infinite expansion.
- --
- The opinions expressed in this message are my own personal views
- and do not reflect the official views of Microsoft Corporation.
- In fact, I'm just a subcontractor, not an employee, so pull in your claws.
-
-